﻿<UserControl x:Class="VrPlayer.Views.ControlPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converters="clr-namespace:VrPlayer.Helpers.Converters;assembly=VrPlayer.Helpers"
             mc:Ignorable="d">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibility"/>
        <converters:InvertBooleanToVisibilityConverter x:Key="InvertBooleanToVisibility"/>
        <converters:TimeFormatConverter x:Key="TimeFormat"/>
    </UserControl.Resources>
    <StatusBar Visibility="{Binding Path=State.MediaPlugin.Content.HasDuration, Converter={StaticResource BooleanToVisibility}}">
        <StatusBar.ItemsPanel>
            <ItemsPanelTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                </Grid>
            </ItemsPanelTemplate>
        </StatusBar.ItemsPanel>
        <StatusBarItem Grid.Column="0">
            <WrapPanel>
                <Button Height="25" Width="25" Command="{Binding Path=State.MediaPlugin.Content.PlayCommand}"
                        Visibility="{Binding Path=State.MediaPlugin.Content.IsPlaying, Converter={StaticResource InvertBooleanToVisibility}}">
                    <Image Source="/Medias/Nuvola/48x48/player_play.png"></Image>
				</Button>
                <Button Height="25" Width="25" Command="{Binding Path=State.MediaPlugin.Content.PauseCommand}"
                        Visibility="{Binding Path=State.MediaPlugin.Content.IsPlaying, Converter={StaticResource BooleanToVisibility}}">
                    <Image Source="/Medias/Nuvola/48x48/player_pause.png"></Image>
				</Button>
                <Button Height="25" Width="25" Command="{Binding Path=State.MediaPlugin.Content.StopCommand}">
                    <Image Source="/Medias/Nuvola/48x48/player_stop.png"></Image>
				</Button>
            </WrapPanel>
        </StatusBarItem>
        <StatusBarItem Grid.Column="1" Visibility="{Binding Path=State.MediaPlugin.Content.HasChapters, Converter={StaticResource BooleanToVisibility}}">
            <WrapPanel>
                <Button Height="25" Width="25" Command="{Binding Path=State.MediaPlugin.Content.PreviousCommand}">
                    <Image Source="/Medias/Nuvola/48x48/start.png"></Image>
                </Button>
                <Button Height="25" Width="25" Command="{Binding Path=State.MediaPlugin.Content.NextCommand}">
                    <Image Source="/Medias/Nuvola/48x48/finish.png"></Image>
                </Button>
            </WrapPanel>
        </StatusBarItem>
        <StatusBarItem Grid.Column="2" HorizontalContentAlignment="Stretch">
            <ProgressBar Height="25" Value="{Binding Path=State.MediaPlugin.Content.Progress, Mode=OneWay}" Minimum="0" Maximum="100" MouseDown="ProgressBar_MouseDown" />
        </StatusBarItem>
        <StatusBarItem Grid.Column="3">
            <StackPanel Orientation="Horizontal">
                <Label Content="{Binding Path=State.MediaPlugin.Content.Position, Converter={StaticResource TimeFormat}}"></Label>
                <Label Content="/" IsEnabled="False"></Label>
                <Label Content="{Binding Path=State.MediaPlugin.Content.Duration, Converter={StaticResource TimeFormat}}" IsEnabled="False"></Label>
            </StackPanel>
        </StatusBarItem>
        <StatusBarItem Grid.Column="4">
            <ToggleButton Height="25" Width="25"  Command="{Binding Path=State.MediaPlugin.Content.LoopCommand}" CommandParameter="{Binding Path=IsChecked, RelativeSource={RelativeSource Self}}">
                <Image Source="/Medias/Nuvola/48x48/noatunloopsong.png"></Image>
            </ToggleButton>
        </StatusBarItem>
    </StatusBar>
</UserControl>
